<template>
  <div>
    <el-dialog :visible.sync="$parent.openAreaNFC" title="编辑NFC">
      <div class="dialog_div">
        <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
          <el-form-item label="区域编号" prop="">
            <el-input v-model="rowObj.areaNum" readonly placeholder="请输入区域编号" :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
          <el-form-item label="区域名称" prop="">
            <el-input v-model="rowObj.areaName" readonly placeholder="请输入区域名称" :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
          <el-form-item label="NFC-ID" prop="nfcId">
            <el-input v-model="formData.nfcId" placeholder="请输入NFC-ID" :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
          <el-form-item label="NFC-编码" prop="nfcCode">
            <el-input v-model="formData.nfcCode" placeholder="请输入NFC-编码" :style="{ width: '100%' }">
            </el-input>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" align="center">
        <el-button @click="() => $parent.openAreaNFC = false">取消</el-button>
        <el-button type="primary" @click="handleConfirm">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { putUpdateNFCstatus } from "@/api/equipment/equipment.js";
export default {
  name: 'updateNfc',
  components: {},
  props: ['rowObj'],
  data () {
    return {
      formData: {
        "nfcId": "", //NFC ID
        "nfcCode": "", //NFC编码
        "areaId": 1 //区域id
      },
      rules: {
        nfcId: [{
          required: true,
          message: '必填',
          trigger: 'blur'
        }],
        nfcCode: [{
          required: true,
          message: '必填',
          trigger: 'blur'
        }],
      },
      placesOptions: [],
    }
  },
  computed: {},
  watch: {},

  mounted () { this.getinit() },
  methods: {
    getinit () {
      this.formData.nfcId = this.rowObj.nfcId
      this.formData.nfcCode = this.rowObj.nfcCode
    },
    handleConfirm () {//提交方法
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        let params = {
          ...this.formData,
          areaId: this.rowObj.areaId
        }
        putUpdateNFCstatus(params).then(res => {
          this.$parent.openAreaNFC = false
          this.$emit('handleSelectList')
          this.$message.success(res.msg)
        })
      })
    },
  }
}

</script>
<style lang="scss" scoped>
.dialog_div {
  width: 60%;
  margin: 0 auto;
}
</style>
